using System;
using Config;
using MoonFramework.Scripts.Tool.System.Setting;
using MoonFramework.Template;
using MoonFramework.Test;
using Tool;
using Tool.Name;
using Unity.VisualScripting;
using UnityEngine;

namespace Data
{
	/// <summary>
	/// 玩家物品的动态数据
	/// </summary>
	public class ItemData
	{
		public int ConfigID;
		public IItemTypeData ItemTypeData;

		public ItemConfig Config => ConfigManager.Instance.GetConfig<ItemConfig>(ConfigName.Item, ConfigID);

		public static ItemData CreateItemData(int configID)
		{
			ItemData itemData = new()
			{
				ConfigID = configID
			};
			//根据物品的实际类型 来创建符合类型的动态数据
			itemData.ItemTypeData = itemData.Config.ItemType switch
			{
				ItemType.Weapon =>
					new ItemWeaponData { Durability = 100 },
				ItemType.Consumable => new ItemConsumableItemData { Count = 1 },
				ItemType.Material => new ItemMaterialItemData { Count = 1 },
				_ => throw new ArgumentOutOfRangeException()
			};
			return itemData;
		}
	}
}
